package com.reviewcode.cachemicroservice.common;

import lombok.Getter;
import lombok.Setter;

/**
 * @author vcorazon
 * @type Class
 * @description TODO
 * @since 2021/07/22 22:12
 */
@Getter
@Setter
public class GenericResponse {
    private Integer code;
    private String msg;
    private String data;

    public GenericResponse(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
        this.data = null;
    }

    public GenericResponse(Integer code, String msg, String data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static GenericResponse success(){
        return new GenericResponse(200, "success");
    }

    public static GenericResponse success(String data){
        return new GenericResponse(200, "success", data);
    }

    public static GenericResponse fail(String errMsg){
        return new GenericResponse(500, errMsg);
    }
}
